package static_;

/**
 * @Package: static_
 * @ClassName: StaticFunction
 * @Author: x2606
 * @CreateTime: 2022/3/10 15:07
 * @Description: 静态方法 类方法
 */

public class StaticFunction {
    public static void main(String[] args) {
        Stu tom = new Stu("Tom");
        Stu jack = new Stu("Jack");

        tom.payFee(1000);
        tom.displayFee();
        jack.payFee(2300);
        jack.displayFee();
        Stu.displayFee();
    }
}

class Stu  {
    private String name;
    //静态变量统计学费
    private static double fee=0;

    public Stu(String name) {
        this.name = name;
    }

    public static void payFee(double fee){
        Stu.fee+=fee;
    }

    public static void displayFee(){
        System.out.println("总学费："+Stu.fee);
    }
}
